function好難


Q1: 請問以下會輸出什麼內容?

let x = y(function z() {
 console.log('I am z') 
})
function y(fn) {
  fn()
  console.log('I am y')
  return fn
}
x()
console.log(y)  
console.log(x)  
console.log(x === y)
answer
I am z
I am y
I am z
[Function: y]
[Function: z]
false

參考文章覺得 JavaScript function 很有趣的我是不是很奇怪








你可能感興趣的文章

pWnOS v2.0 Walkthrough

pWnOS v2.0 Walkthrough

Airflow 動手玩:(七)Airflow Best Practices

Airflow 動手玩:(七)Airflow Best Practices

Leetcode JS 2676. Throttle

Leetcode JS 2676. Throttle






留言討論